import uuid
from django.db import models


class Organization(models.Model):
    name = models.CharField('名称', max_length=50, db_index=True)
    type = models.CharField('类型', choices=(('develop', '开发'), ('operation', '运维'), ('product', '产品'), ('test', '测试')),
                            max_length=64)

    def __str__(self):
        return self.name

    class Meta:
        verbose_name = u'组织'
        verbose_name_plural = u'组织'
        db_table = 'group'


# Create your models here.
class Staff(models.Model):
    uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    name = models.CharField('姓名', max_length=50, null=True, blank=True, )
    id = models.BigIntegerField('工号', null=True, blank=True, db_index=True)
    group = models.ForeignKey(Organization, blank=True, null=True,on_delete=models.CASCADE, related_name='+', verbose_name='组织')

    def __str__(self):
        return self.name

    class Meta:
        verbose_name = u'人员'
        verbose_name_plural = u'人员'
        db_table = 'staff'
